package com.preskool.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author kennyzzz
 * @Data 2021/1/6 15:43
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.preskool";
    public static final String VERSION = "1.0";
    @Bean
    public Docket getDecket(){
        /**
         * 访问http://localhost:8008/swagger-ui.html
         */
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                //api包扫描路径
                .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE))
                //可以根据url路径设置哪些请求加入文档,忽略哪些请求
                .paths(PathSelectors.any())
                .build();
    }
    @SuppressWarnings("deprecation")
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                //设置文档的标题
                .title("教务管理系统接口文档说明")
                //设置文档的描述信息
                .description("本章更新:Transport模块与Library模块")
                //设置文档的license信息
//                .termsOfServiceUrl("http://localhost:8080/myswagger/api")
//                //设置文档的联系方式
//                .contact(new Contact("my-boot","http://www.kennyzzz.com","625274188@qq.com"))
                .version(VERSION)  //设置文档的版本信息
                .build();
    }
}
